﻿using TestBat.IModels.Domain;
using NHibernate.Validator.Constraints;

namespace TestBat.Models.Domain
{
    public abstract class Solution : DomainEntity, ISolution
    {
        [NotNull]
        public virtual ITestTask Task { get; set; }

        public abstract int? GetPercentage();

        public abstract bool IsEmtpy { get; }

        /// <summary>
        /// is the solution graded?
        /// </summary>
        public virtual bool IsGraded
        {
            get
            {
                return GetPercentage().HasValue;
            }
        }

        public virtual float? Points
        {
            get
            {
                if (GetPercentage().HasValue)
                    return Task.MaximumPoints * GetPercentage() / 100.0f;
                else
                    return null;
            }
        }
    }
}
